package com.youhong.teethcare.adapter

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import com.youhong.teethcare.R

class CommonProblemAdapter (val titles:Array<String>,val contents:Array<String>):RecyclerView.Adapter<CommonProblemAdapter.CommonProblemViewHolder>(){

    class CommonProblemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

        var tvTilte= itemView.findViewById<TextView>(R.id.tvProblemTitle)
        var tvContent= itemView.findViewById<TextView>(R.id.tvProblemContent)

    }

    override fun onCreateViewHolder(parent: ViewGroup, p1: Int): CommonProblemViewHolder {

        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_common_problem, parent, false);
        return CommonProblemViewHolder(view);
    }

    override fun onBindViewHolder(viewholder: CommonProblemViewHolder, position: Int) {
        var title= titles[position]
        var content=contents[position]
        viewholder.tvContent.text=content
        viewholder.tvTilte.text=title
    }

    override fun getItemCount(): Int {
       return titles.size
    }
}